package com.bite.product.controller;

import com.bite.product.model.ProductInfo;
import com.bite.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping("/{productId}")
    public ProductInfo getProductById(@PathVariable("productId") Integer id){
        return productService.selectProductById(id);
    }

    @GetMapping("/p1")
    public String p1(Integer id){
        return "获得参数"+id;
    }

    @GetMapping("/p2")
    public String p2(String name, Integer id){
        return "接收到:"+name+id;
    }

    @GetMapping("/p3")
    public String p3(ProductInfo productInfo){
        return productInfo.toString();
    }

    @RequestMapping("/p4")
    public ProductInfo p4(@RequestBody ProductInfo productInfo){
        return productInfo;
    }
}
